import { useloginApi } from "@/api/index";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    showLoading: false,
    formdata: {
      username: "",
      password: "",
    },
  },
  oninput(e) {
    let { type, value } = e.detail;
    let { formdata } = this.data;
    if (type === "username") {
      this.setData({
        "formdata.username": value,
      });
    }
    if (type === "password") {
      this.setData({
        "formdata.password": value,
      });
    }
  },
  // 登录
  async login() {
    // this.setData({
    //   showLoading: true,
    // });
    let { formdata } = this.data;
    console.log("login");
    let {
      data: { token },
    } = await useloginApi(formdata);
    wx.setStorageSync("token", token);
    wx.reLaunch({
      url: "/pages/login/tenant/tenant",
    });
    // this.setData({
    //   showLoading: false,
    // });
  },
});
